package com.ruoyi.base.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 树形
 */
@Data
public class TreeVo {
    private Long id;
    private Long parentId;
    private String label;
    private String type;

    private List<TreeVo> children;

    public TreeVo(){};

    public TreeVo(Long id, Long parentId, String label, String type) {
        this.id = id;
        this.parentId = parentId;
        this.label = label;
        this.type = type;
    }

    public void addChild(TreeVo child){
        if(children == null){
            children = new ArrayList<>();
        }
        children.add(child);
    }
}
